package com.ruoyi.web.controller.warning;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.warning.domain.entity.Customoids;
import com.ruoyi.warning.domain.query.CustomoidsQuery;
import com.ruoyi.warning.service.ICustomoidsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenhc
 * @since 2025-05-08
 */
@RestController
@RequestMapping("/customoids")
@Api(tags = "自定义oid", description = "用于处理自定义oid相关操作的控制器")
public class CustomoidsController {
    @Resource
    private ICustomoidsService iCustomoidsService;
    @ApiOperation("分页")
    @Log(title = "查询联系人", businessType = BusinessType.SELECT)
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/page")
    public R<TableDataInfo> page(CustomoidsQuery query)
    {
        return R.ok(iCustomoidsService.getPage(query));
    }

    @ApiOperation("详情")
    @Log(title = "查询联系人", businessType = BusinessType.SELECT)
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/detail/{id}")
    public R detail(@PathVariable Integer id)
    {
        return R.ok(iCustomoidsService.getById(id));
    }

    @ApiOperation("增加或修改")
    @Log(title = "查询联系人", businessType = BusinessType.SELECT)
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @PostMapping(value = "/saveOrUpdate")
    public R saveOrUpdate(@RequestBody Customoids customoids)
    {
        iCustomoidsService.saveOrUpdate(customoids);
        return R.ok();
    }

    @ApiOperation("删除")
    @Log(title = "查询联系人", businessType = BusinessType.SELECT)
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/delete/{id}")
    public R delete(@PathVariable Integer id)
    {
        iCustomoidsService.removeById(id);
        return R.ok();
    }
}
